import { defineConfig } from 'vite';
import uni from '@dcloudio/vite-plugin-uni';
import vueJsx from '@vitejs/plugin-vue-jsx';
import { resolve } from 'path';
import UnoCSS from 'unocss/vite'
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from '@vant/auto-import-resolver';

export default defineConfig({
	build: {
		target: 'es6',
	},
	resolve: {
		alias: [
			{
				find: '@',
				replacement: resolve(__dirname, 'src'),
			},
		],
	},
	server: {
		port: 1314,
		// 选项写法
		proxy: {
			'/api': {
				target: '',
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/api/, '/api'),
			},
		},
	},
	plugins: [uni(), vueJsx(), UnoCSS(),
	Components({
		resolvers: [VantResolver()],
	}),],
});
